<template>
    <div class="listbox">
        <div class="first-mt10-no" v-if="listbox && (JSON.stringify(listbox) !== '[]')">
            <div class="active mt10" v-for="(item, i) in listbox" :ca="'发现_发现$'+item.title">
                <div class="banner">
                    <a href="javascript:void(0)" :thref="item.detailsUrl" @click="openNewView(item.id, item.detailsUrl)" >
                        <img :src="item.image" alt="" />
                        <div class="video-icon" v-if="item.type == 1"><img src="../../../assets/image/discover/video-icon.png" /></div>
                    </a>
                    <!-- type == 1 [视频] , 2 [文章]-->
                    <!--<i class="icon-video icon-video-1" v-if="item.type == 1" :style="'background-image: url(' + require('../../../assets/image/discover/view_01.png') + '); background-size: contain; width: 28px; height: 28px; display: block;'"></i>
                    <i v-else :style="'background-image: url(' + require('../../../assets/image/discover/view_02.png') + '); background-size: contain; width: 28px; height: 28px; display: block; background-repeat: no-repeat;'" class="icon-video"></i>-->
                    <i v-if="item.type == 1 && item.videoTime" class="icon-time"><em></em>{{item.videoTime}}</i>
                    <!-- 不是首页显示角标  【1，显示在首页】, 【0，不显示在首页】 iconShow 【1，显示icon】 【0，显示icon】 -->
                    <span class="icon" v-if="item['iconShow'] == 1" :style="'background-image: url('+item.icon+');'"></span>
                </div>
                <div class="content">
                    <h3 v-html="item.title"></h3>
                    <div class="sub-content">
                        <h5 class="fl" v-html="item.subTitle"></h5>
                        <span class="icon-video num fr" style="color:#b0bbc5;"> 
                            <!--<i class="icon-video icon-video-1" v-if="item.type == 1" :style="'background-image: url(' + require('../../../assets/image/discover/b_02.png') + '); background-size: contain; background-repeat: no-repeat;'"></i>-->
                            <!-- （基数 + 接口浏览量）超过万显示万，小余万，显示当前增加后的数字  -->
                            <!--<i v-else :style="'background-image: url(' + require('../../../assets/image/discover/b_01.png') + '); background-size: contain; background-repeat: no-repeat;'" class="icon-video"></i>-->
                            <i :style="'background-image: url(' + require('../../../assets/image/discover/b_01.png') + '); background-size: contain; background-repeat: no-repeat;'" class="icon-video"></i>
                            {{(parseInt(item['pageViewDefault']) + parseInt(item.view))>10000 ? parseInt((parseInt(item['pageViewDefault']) + parseInt(item.view))/10000) : parseInt((parseInt(item['pageViewDefault']) + parseInt(item.view)))}}
                            <b v-show="(parseInt(item['pageViewDefault']) + parseInt(item.view))>10000" style="font-style: normal; font-weight: normal;">万</b>
                        </span>
                    </div>
                    <em v-if="listbox.length-1 != i"></em>
                </div>
            </div>
        </div>
        <div v-show="listbox && !(JSON.stringify(listbox) !== '[]')" style="display: none; text-align: center; justify-content: center; padding-top: 100px; color: #8392a0; font-size: 16px;">暂无数据</div>
    </div>
</template>


<script>
	import common from "../../../assets/js/common.js";  
    import { videoPlayer } from 'vue-video-player'; 
    require('videojs-resolution-switcher');
	export default {
	    name: 'listbox', 
	    data: function() {
	        return {
	            listData: []
	        }
	    },
	    props: ['listbox'],
	    mounted: function() {
	        // 清除 文章id
	        sessionStorage.setItem('id', '');
	    },
	    updated: function() {
	        //打点
	        this.$nextTick(function () {
	            common.ANA_AnalyticsScan();
	        });
	    },
        methods: {
            /**
             * id传递到详情页
             */
            openNewView:function(id, src){
                var host = window.location.origin;
                
                // 设置id
                sessionStorage.setItem('id', id);
                
                // 判断链接
                if(common.getChannel()!='appCode'){  
                   window.location.href = host+src;               
                }else{ 
                    if(document.querySelector('#vjs_video_3_html5_api')){
                        var myPlayer = videojs('vjs_video_3_html5_api');       
                        myPlayer.pause();  
                    }
                    lb.newWebview({'url':host+src});
                }
            }
        }
	}
	
</script>

<style lang="scss">
   
@function rem($px){
  @return $px / 10 * 1rem;
}  
 
@mixin ban_line{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
} 
  
$_fff: #fff;
$_243742: #243742; 

$sans-serif: "PingFangSC-Regular,'Helvetica Neue', Helvetica, Rotobo";
$font-family: $sans-serif;
   
.mt10 {
    margin-top: rem(10);
} 
.first-mt10-no div:nth-child(1) {
    margin-top: 0;
}

.sub-content {
    overflow: hidden;
    margin-top: rem(7);
} 

.video-icon {
    width: rem(52);
    height: rem(52);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}
.active .banner .video-icon img {
    width: 100%;
    height: 100%;
    display: inline-block;
}
 
.active{
    background:$_fff;
    .banner img{
        width: 100%;
        height:rem(160);
    }
    .banner{
        position: relative;
        .icon {
            width: rem(44);
            height: rem(44);
            background-size: contain;
            background-repeat: no-repeat;
            position: absolute;
            left: 0;
            top: 0;
        }
        i.icon-video{
            width:rem(28);
            height:rem(28);
            background: rgba(0, 0, 0, 0.37);
            border-radius:rem(28);
            display:inline-block;
            position: absolute;
            left:rem(17);
            bottom:rem(7);
            text-align:center;
            color:#fff;
        }
        i.icon-time{
            display: inline-block;
            width:rem(55);
            height:rem(17);
            position: absolute;
            bottom:rem(12);
            right:rem(17);
            background:rgba(0, 0, 0, 0.37);
            color:#fff;
            text-align:center;
            line-height:rem(17);
            font-size:rem(12);
            font-style: normal;
            em {
               width: rem(12); 
               height: rem(12); 
               background: url('../../../assets/image/discover/time.png') center center no-repeat;
               background-size: cover;
               display: inline-block;
               margin-left: rem(4);
               float: left;
               margin-top: rem(2);
            }
        }
    }
    .content{
        /*padding:rem(10) rem(25);*/
        padding: rem(20) 0;
        overflow: hidden;        
        h3{
            font-size:rem(16);
            line-height: 130%;
            color:$_243742;
        }
        h5 {
            width: rem(500/2);
            font-size: rem(13);
            color: #8392a0;
            @include ban_line;
        }
        /*h5{
            font-size:rem(13);
            line-height: 130%;
            color:#8392a0;
            margin-top: rem(6);
        }*/
        em {
            display: block;
            /*margin: rem(10) 0;*/
            margin: rem(20) 0 0 0;
            /*width: rem(60);*/
            height: 1px;
            background: #c9d5e0;
            transform: scaleY(.5);  
        }
        .icon-video i{
            width:rem(20);
            height:rem(10);
            display:inline-block;
        }
        .icon-video{
            font-size:rem(12);
            line-height:rem(17);
        }
    }
}   

h1,h2,h3,h4,h5 {
    -webkit-margin-before: 0em;
    -webkit-margin-after: 0em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
}
    
</style>